package com.rcklos.NettyLentMe.netty.channel;

import com.rcklos.NettyLentMe.netty.interfaces.ChannelPoolInterfaces;
import io.netty.channel.Channel;
import io.netty.util.AttributeKey;

/**
 * @// TODO: 2020/10/5 通道连接池管理器
 * @author 20152 
 * @date 2022年12月5日 13点21分
 */
public class ChannelPool implements ChannelPoolInterfaces {

    public static final String ATTR_KEY_TIMESTAMP = "TIME_STAMP";
    public static final String ATTR_KEY_TEMPNAME  = "TEMP_NAME";
    public static final String ATTR_KEY_USER_ID = "USER_ID";

    private static ChannelPool instance;

    public static ChannelPool getInstance() {
        if( instance == null ){
            synchronized (ChannelPool.class){
                instance = new ChannelPool();
            }
        }
        return instance;
    }

    private ChannelPool(){
        // 各种池的管理
    }

    @Override
    public void put(Channel channel) {

    }

    @Override
    public void del(Channel channel) {

    }

    @Override
    public Channel get(String key) {
        return null;
    }

    @Override
    public String getAttr(Channel channel, String attr_key) {
        return null;
    }

    @Override
    public void addLongConnect(String key, Channel channel) {

    }

    @Override
    public void delLongConnect(String key) {

    }

    @Override
    public void exceptionCaught(Channel channel, Throwable cause) {
        System.out.println("连接异常-->cause:"  + channel.attr(AttributeKey.valueOf(ChannelPool.ATTR_KEY_TEMPNAME)).get()+cause.getMessage());
    }
}
